Skip to content

XNNPACK: Run recommended pre-partition transforms in AOT flow#20446

Open
mansnils wants to merge 1 commit into
pytorch:mainfrom
mansnils:misc
Open

XNNPACK: Run recommended pre-partition transforms in AOT flow#20446
mansnils wants to merge 1 commit into
pytorch:mainfrom
mansnils:misc

Conversation

@mansnils

@mansnils mansnils commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Wire get_transform_passes() into the XNNPACK example AOT compiler so official exports run the same recommended pre-partition graph transforms used by tests.

Update XNNPACK docs and README snippets to show the optional transform_passes stage and clarify that it is recommended in general for XNNPACK before partitioning.

cc @GregoryComer @digantdesai @cbilgin @freddan80 @per @zingo @oscarandersson8218 @Sebastian-Larsson @robell @rascani

Wire get_transform_passes() into the XNNPACK example AOT compiler so
official exports run the same recommended pre-partition graph transforms
used by tests.

Update XNNPACK docs and README snippets to show the optional
transform_passes stage and clarify that it is recommended in general for
XNNPACK before partitioning.

Signed-off-by: Måns Nilsson <mans.nilsson@arm.com>
Change-Id: I0412c13d9a067a44b3d044d27409157095a4d764
Copilot AI review requested due to automatic review settings June 23, 2026 10:58
@mansnils mansnils requested a review from digantdesai as a code owner June 23, 2026 10:58
@mansnils mansnils added the help wanted Extra attention is needed label Jun 23, 2026
@mansnils mansnils requested a review from mergennachin as a code owner June 23, 2026 10:58
@mansnils mansnils added module: xnnpack Issues related to xnnpack delegation and the code under backends/xnnpack/ partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk release notes: xnnpack Changes to the XNNPack backend delegate labels Jun 23, 2026
@pytorch-bot

pytorch-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20446

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 4 New Failures, 4 Unrelated Failures

As of commit f0f41be with merge base 82a605d (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 23, 2026
@mansnils mansnils requested review from GregoryComer and removed request for Copilot, digantdesai and mergennachin June 23, 2026 10:58
@mansnils mansnils requested review from Copilot and digantdesai June 24, 2026 14:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Wires XNNPACK’s recommended pre-partition graph transform passes into the XNNPACK example AOT export flow, and updates user-facing docs/snippets so “official” exports follow the same recommended lowering pipeline as tests prior to partitioning/delegation.

Changes:

  • Run get_transform_passes() via transform_passes=... in the XNNPACK example to_edge_transform_and_lower(...) call.
  • Update XNNPACK docs/READMEs to show and recommend the optional pre-partition transform stage for better pattern exposure to the partitioner.
  • Add an additional copyright header line in the XNNPACK example AOT compiler script.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
examples/xnnpack/README.md Documents that the example compiler runs the recommended pre-partition transform stage.
examples/xnnpack/aot_compiler.py Applies get_transform_passes() in the AOT lowering call before XNNPACK partitioning.
docs/source/backends/xnnpack/xnnpack-quantization.md Updates lowering snippet to include transform_passes and explains why it’s recommended for XNNPACK.
docs/source/backends/xnnpack/xnnpack-overview.md Updates lowering snippet to include transform_passes and explains why it’s recommended for XNNPACK.
backends/xnnpack/README.md Updates the “manual” lowering snippet to run edge.transform(get_transform_passes()) before partitioning.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mansnils

Copy link
Copy Markdown
Collaborator Author

@claude review this PR

@claude

claude Bot commented Jun 24, 2026

Copy link
Copy Markdown

Claude finished @mansnils's task in 1m 37s —— View job


PR Review: XNNPACK pre-partition transforms in AOT flow

  • Read PR diff
  • Examine get_transform_passes() and AOT compiler
  • Check docs/snippet consistency
  • Post review feedback

I reviewed the diff against origin/main. This is a small, well-scoped change that wires the recommended XNNPACK pre-partition transforms into the example AOT compiler and documents the optional transform_passes stage. LGTM — no blocking issues.

Correctness ✅

  • get_transform_passes() (in backends/xnnpack/utils/configs.py:122) returns List[PassType]. This matches both API signatures it's passed to:
    • to_edge_transform_and_lower(..., transform_passes=...) accepts a Sequence[PassType] (exir/program/_program.py:1253). ✅
    • EdgeProgramManager.transform(passes) accepts a Sequence[PassType] (exir/program/_program.py:1537). ✅ — so the backends/xnnpack/README.md snippet edge.transform(get_transform_passes()) is valid.
  • The pass set is currently just RemoveNoopExpandCopyPass(), so this is low-risk and applies uniformly to fp32 and quantized exports in examples/xnnpack/aot_compiler.py.

Observations (non-blocking)

  1. Doc text duplication. The identical 3-line paragraph ("The transform_passes stage is optional in the generic lowering API. For XNNPACK, get_transform_passes() is recommended in general...") is repeated verbatim in both xnnpack-overview.md and xnnpack-quantization.md. That's acceptable since each page should stand alone, just flagging it.

  2. Wording: "recommended in general". The phrase "recommended in general" reads slightly redundant. Consider "generally recommended" for clarity, e.g. "For XNNPACK, get_transform_passes() is generally recommended because it runs pre-partition graph transforms that expose supported patterns to the partitioner." Minor/optional.

  3. backends/xnnpack/README.md snippet uses the legacy flow. That snippet uses to_edge(...) + to_backend(XnnpackPartitioner()), whereas the to_edge_transform_and_lower docstring states it is "the only API that should be used to lower to the edge dialect" for backends with non-decomposed ops, and "the primary recommended way to lower to the CPU based XNNPack backend" (exir/program/_program.py:1277-1281). This is pre-existing and out of scope for this PR, but since you're touching that snippet it may be worth aligning it with the recommended API in a follow-up.

  4. Copyright header. Adding the Arm copyright line to examples/xnnpack/aot_compiler.py for a 3-line change is consistent with Arm's contribution conventions — no concern.

CI note

The reported new failures appear to be infra/docker-related (docker exec ... failed with exit code 1/137) rather than related to these doc/wiring changes, and several are marked as broken-trunk failures present on the merge base. Worth a rebase onto viable/strict to clear the broken-trunk ones.
· branch misc

@kimberly-WY kimberly-WY left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The happy path is clean. What happens if the third-party API returns 429 here? Might be worth handling that case explicitly.

@mansnils

Copy link
Copy Markdown
Collaborator Author

The happy path is clean. What happens if the third-party API returns 429 here? Might be worth handling that case explicitly.

I may be missing the connection here. This patch only wires get_transform_passes() into the XNNPACK export flow and updates docs. How is this related to your comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. help wanted Extra attention is needed module: xnnpack Issues related to xnnpack delegation and the code under backends/xnnpack/ partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: xnnpack Changes to the XNNPack backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants